package base;

import android.app.Application;
import android.os.Handler;
import android.os.Looper;

/**
 * Created by LiJZ on 2016/7/28.
 */
public class BaseApplication extends Application {
	// 获取到主线程的上下文
	private static BaseApplication mContext;
	// 主线程的id
	private static int mMainThreadId;
	// 获取到主线程
	private static Thread mMainThread;
	// 获取到主线程的handler
	private static Handler mMainThradHandler;
	// 获取到主线程的looper
	private static Looper mMainThradLooper;

	@Override
	public void onCreate() {
		super.onCreate();
		this.mContext = this;
		this.mMainThreadId = android.os.Process.myTid();
		this.mMainThread = Thread.currentThread();
		this.mMainThradHandler = new Handler();
		this.mMainThradLooper = getMainLooper();
	}

	public static BaseApplication getApplication() {
		return mContext;
	}

	public static int getMainThreadId() {
		return mMainThreadId;
	}

	public static Thread getMainThread() {
		return mMainThread;
	}

	public static Handler getMainThreadHandler() {
		return mMainThradHandler;
	}

	public static Looper getMainThreadLooper() {
		return mMainThradLooper;
	}
}
